package o;

import android.util.Log;
import java.io.File;
import java.io.IOException;
import o.rm.b;
import o.rm.c;

public class ur implements uj {
    private final uw ˊ;
    private final uo ˋ = new uo();
    private final long ˎ;
    private rm ˏ;
    private final File ॱ;

    public static uj ˋ(File file, long j) {
        return new ur(file, j);
    }

    @Deprecated
    protected ur(File file, long j) {
        this.ॱ = file;
        this.ˎ = j;
        this.ˊ = new uw();
    }

    private synchronized rm ॱ() throws IOException {
        if (this.ˏ == null) {
            this.ˏ = rm.ॱ(this.ॱ, 1, 1, this.ˎ);
        }
        return this.ˏ;
    }

    public File ˋ(sa saVar) {
        String ॱ = this.ˊ.ॱ(saVar);
        if (Log.isLoggable("DiskLruCacheWrapper", 2)) {
            Log.v("DiskLruCacheWrapper", "Get: Obtained: " + ॱ + " for for Key: " + saVar);
        }
        File file = null;
        try {
            c ˎ = ॱ().ˎ(ॱ);
            if (ˎ != null) {
                file = ˎ.ˋ(0);
            }
        } catch (Throwable e) {
            if (Log.isLoggable("DiskLruCacheWrapper", 5)) {
                Log.w("DiskLruCacheWrapper", "Unable to get from disk cache", e);
            }
        }
        return file;
    }

    public void ˊ(sa saVar, uj.c cVar) {
        String ॱ = this.ˊ.ॱ(saVar);
        this.ˋ.ˋ(ॱ);
        b ˏ;
        try {
            if (Log.isLoggable("DiskLruCacheWrapper", 2)) {
                Log.v("DiskLruCacheWrapper", "Put: Obtained: " + ॱ + " for for Key: " + saVar);
            }
            rm ॱ2 = ॱ();
            if (ॱ2.ˎ(ॱ) != null) {
                this.ˋ.ॱ(ॱ);
                return;
            }
            ˏ = ॱ2.ˏ(ॱ);
            if (ˏ == null) {
                throw new IllegalStateException("Had two simultaneous puts for: " + ॱ);
            }
            if (cVar.ˎ(ˏ.ॱ(0))) {
                ˏ.ˎ();
            }
            ˏ.ॱ();
            this.ˋ.ॱ(ॱ);
        } catch (Throwable e) {
            if (Log.isLoggable("DiskLruCacheWrapper", 5)) {
                Log.w("DiskLruCacheWrapper", "Unable to put to disk cache", e);
            }
        } catch (Throwable th) {
            this.ˋ.ॱ(ॱ);
        }
    }
}
